home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / wild / support / precalc_shadepalettei.bas < prev    next >
BASIC Source File  |  1999-01-01  |  2KB  |  80 lines

  1. '$include basu:_command.bas
  2. '$include basu:_cut.bas
  3. '$include basu:_filereq.bas
  4. '$include basu:_loadpalette.bas
  5.  
  6. ' That makes a table of palettes, from the darkest to the brightest.
  7. ' There are 64 shades from 0 to 255 intensity, wich are calced looking
  8. ' for the color with the luminosity. So, the last palette is the real
  9. ' palette, NOT a brighter palette.
  10. ' Then, for specialfx, I add 64 more shades, and those colors are
  11. ' calced with the normal color added at $iiiiii. The max $ii is 255.
  12. ' That's good to draw transparent objects (not coloured, with this...)
  13.  
  14. '''pal$=FileReq$("WildPJ:Libs/Wild/Draw","Select a RGB32 palette","#?.rgb32")
  15. pal$="EscapeLevels:BackGrounds/Various1.rgb32"
  16.  
  17. FUNCTION BestCol(RF%,GF%,BF%,ER%,EG%,EB%)
  18.  SHARED R%(),G%(),B%()
  19.  LOCAL p%,BER&,CER&,CEG&,CEB&,BC%,CE&
  20.  BER&=2^20
  21.  FOR p%=0 TO 255
  22.   CER&=ABS(R%(p%)-RF%)*ER%
  23.   CEG&=ABS(G%(p%)-GF%)*EG%
  24.   CEB&=ABS(B%(p%)-BF%)*EB%
  25.   CE&=CER&+CEG&+CEB&
  26.   IF CE&<BER& THEN BER&=CE&:BC%=p%
  27.  NEXT p%
  28.  BestCol=BC%
  29. END FUNCTION
  30.  
  31. DIM Table(127,255)    'pal,col
  32. IF pal$<>""
  33.  SCREEN 1,640,256,8,5
  34.  WINDOW 1,"Palette Shades Creator",,,1
  35.  CALL LoadPalette(pal$,1)
  36.  CLS
  37.  sx=WINDOW(2)/15
  38.  sy=WINDOW(3)/15
  39.  
  40.  FOR i=63 TO 0 STEP -1
  41.   FOR c=0 TO 255 
  42.    RTF=R%(c)+(i+1)*4
  43.    GTF=G%(c)+(i+1)*4
  44.    BTF=B%(c)+(i+1)*4
  45.    IF RTF>255 THEN RTF=255
  46.    IF GTF>255 THEN GTF=255
  47.    IF BTF>255 THEN BTF=255
  48.    
  49.    BC%=BestCol(RTF,GTF,BTF,1,1,1)
  50.    
  51.    PSET (c,i+64),BC%
  52.    Table(i+64,c)=BC%
  53.   NEXT c
  54.  NEXT i
  55.  
  56.  FOR i=63 TO 0 STEP -1
  57.   FOR c=0 TO 255
  58.    RTF=R%(c)*(i+1)/64
  59.    GTF=G%(c)*(i+1)/64
  60.    BTF=B%(c)*(i+1)/64
  61.    
  62.    BC%=BestCol(RTF,GTF,BTF,1,1,1)
  63.    
  64.    PSET (c,i),BC%
  65.    Table(i,c)=BC%
  66.   NEXT c
  67.  NEXT i
  68.  
  69.  OPEN "RAM:Palette.preka" FOR OUTPUT AS 1
  70.   FOR i=0 TO 127
  71.    FOR c=0 TO 255
  72.     PRINT #1,CHR$(Table(i,c));
  73.    NEXT c
  74.   NEXT i
  75.  CLOSE 1
  76. END IF
  77.  
  78.  
  79.  
  80.